<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <ul>
      <li>知道知道,点我应有弹框在手</li>
      <li>知道知道,点我应有弹框在手</li>
      <li>知道知道,点我应有弹框在手</li>
      <li>知道知道,点我应有弹框在手</li>
    </ul>
    <script>
      var ul = document.querySelector('ul');
      ul.addEventListener('click', function (e) {
        //如果点击li事件我会把
        //e.target 点谁 就改变谁的颜色
        var lis = document.querySelectorAll('li');
        for (var i = 0; i < lis.length; i++) {
          lis[i].style.backgroundColor = '';
        }
        e.target.style.backgroundColor = 'pink';
      });
    </script>
  </body>
</html>
